import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/colors/gf_color.dart';
import 'package:getwidget/components/alert/gf_alert.dart';
import 'package:getwidget/components/button/gf_button.dart';
import 'package:getwidget/components/floating_widget/gf_floating_widget.dart';
import 'package:getwidget/types/gf_alert_type.dart';

import '../controllers/gfalert_controller.dart';

class GfalertView extends GetView<GfalertController> {
  var alertWidget = null;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('弹窗'),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.all(10),
        child: ListView(
          children: [
            Obx(() {
              return GFFloatingWidget(
                verticalPosition: 150,
                showBlurness: controller.showBlur.value,
                child: alertWidget,
                body: Column(
                  children: [
                    Container(
                      margin: const EdgeInsets.only(top: 20),
                      color: Colors.transparent,
                      child: Center(
                        child: GFButton(
                          text: 'Tap to View',
                          onPressed: () {
                            controller.showBlur.value = true;
                            alertWidget = GFAlert(
                              alignment: Alignment.center,
                              backgroundColor: Colors.white,
                              title: 'Welcome!',
                              content:
                              'Get Flutter is one of the largest Flutter open-source UI library for mobile or web apps with  1000+ pre-built reusable widgets.',
                              type: GFAlertType.rounded,
                              bottombar: Row(
                                mainAxisAlignment: MainAxisAlignment.end,
                                children: <Widget>[
                                  GFButton(
                                    onPressed: () {
                                      alertWidget = null;
                                      controller.showBlur.value = false;
                                    },
                                    color: GFColors.LIGHT,
                                    child: const Text(
                                      'Close',
                                      style: TextStyle(color: Colors.black),
                                    ),
                                  ),
                                ],
                              ),
                            );
                          }
                        ),
                      ),
                    )
                  ]
                )
              );
            })  
          ],
        ),
      ),
    );
  }
}
